<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "browse".
 *
 * @property string $id
 * @property string $uid
 * @property integer $create_at
 * @property string $website_id
 *
 * @property Website $website
 */
class Browse extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'browse';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'create_at', 'website_id'], 'integer'],
            [['create_at', 'website_id'], 'required'],
            [['website_id'], 'exist', 'skipOnError' => true, 'targetClass' => Website::className(), 'targetAttribute' => ['website_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'uid' => Yii::t('app', 'Uid'),
            'create_at' => Yii::t('app', 'Create At'),
            'website_id' => Yii::t('app', 'Website ID'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getWebsite()
    {
        return $this->hasOne(Website::className(), ['id' => 'website_id']);
    }

    /**
     * @inheritdoc
     * @return BrowseQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new BrowseQuery(get_called_class());
    }
}
